package com.example.demo.componet;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * 读csv到redis种
 *
 * @author xwh
 * @date 2023/01/25
 */
public class ReadCsvToRedis {

    public ReadCsvToRedis(){};

        //java嵌套python的路径
    public ReadCsvToRedis(String filepath){
        try {
            System.out.println("start");
            String[] args1 = new String[]{"python", filepath};    //"D://Python/PycharmProjects/helloworld/read_csv_to_redis.py"   运行的python代码路径
            Process pr = Runtime.getRuntime().exec(args1);

            BufferedReader in = new BufferedReader(new InputStreamReader(
                    pr.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            pr.waitFor();
            System.out.println("end");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    ReadCsvToRedis(String pythonPath,String csvPath){

    }
}
